home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_FONT / Source / shared.subproj / common.c < prev    next >
Text File  |  1995-06-12  |  3KB  |  73 lines

  1. /***********************************************************************
  2. Common c code for Convert programs
  3. Copyright (C) 1993 David John Burrowes
  4.  
  5. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.
  6.  
  7. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  8.  
  9. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  10.  
  11. The author, David John Burrowes, can be reached at:
  12.     davidjohn@kira.net.netcom.com
  13.     David John Burrowes
  14.     1926 Ivy #10
  15.     San Mateo, CA 94403-1367
  16. ***********************************************************************/
  17.  
  18. #import "common.h"
  19. #import <stdlib.h>
  20. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  21. //    This function takes an unsigned number, and returns YES if the number is
  22. //    even, and NO otherwise.
  23. //    This test is accomplished simply by getting the remainder of dividing the number
  24. //    by 2.  This remainder will always be either 0 or 1.  If it is 1, then theNum was
  25. //    odd, otherwise it was even.
  26. //    This function is included here because this is occasionally a thing I need to make
  27. //    use of, but alas I always end up spending too much time remembering the operators
  28. //    needed to do it again.  
  29. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  30.  
  31. Boolean    EvenUnsignedNum (PositiveInteger  theNum)
  32. {
  33.     if  ((theNum % 2) == 1)
  34.         return NO;
  35.     else
  36.         return YES;
  37. }
  38.  
  39.  
  40. CString    NewCString(PositiveInteger length)
  41. {
  42.     CString    temp = (CString) malloc(length+1);
  43.     temp[0] = EndOfCString;
  44.     return temp;
  45. }
  46.  
  47. void    FreeCString(CString theString)
  48. {
  49.     free((char*)theString);
  50. }
  51.  
  52.  
  53. ByteString    NewByteString(PositiveInteger length)
  54. {
  55.     return (ByteString) malloc(length);
  56. }
  57.  
  58. void    FreeByteString(ByteString theString)
  59. {
  60.     free((char*)theString);
  61. }
  62.  
  63.  
  64. Pointer    NewPointer(PositiveInteger length)
  65. {
  66.     return (Pointer) malloc(length);
  67. }
  68.  
  69. void    FreePointer(Pointer thePointer)
  70. {
  71.     free((char*)thePointer);
  72. }
  73.